package com.card.hwatt.entity;

import java.util.Date;
import java.util.List;
import java.util.UUID;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;

/**
 * 班次
 * 
 * @author Administrator
 * 
 */
@Entity
@Table(name = "T_Schedule")
public class Schedule {

	@Id
	@GeneratedValue(generator = "generator")
	@GenericGenerator(name = "generator", strategy = "assigned")
	@Column(name = "ScheduleID", length = 36)
	@Type(type = "uuid-char")
	public UUID id;

	/**
	 * 单位
	 */
	@OneToOne(cascade = {}, fetch = FetchType.EAGER)
	@JoinColumn(name = "DepartmentID", nullable = true)
	public Department department;

	/**
	 * 名称
	 */
	@Column(name = "`Name`", length = 200, nullable = false)
	public String name;

	/**
	 * 开始日期
	 */
	@Column(name = "StartDate", nullable = false)
	public Date startDate;

	/**
	 * 终止日期
	 */
	@Column(name = "EndDate", nullable = false)
	public Date endDate;

	/**
	 * 上午班
	 */
	@ManyToOne(cascade = {})
	@JoinColumn(name = "MorningID", nullable = false)
	public WorkTime morning;

	/**
	 * 下午班
	 */
	@ManyToOne(cascade = {})
	@JoinColumn(name = "AfternoonID", nullable = false)
	public WorkTime afternoon;

	/**
	 * 夜班
	 */
	@ManyToOne(cascade = {})
	@JoinColumn(name = "NightID", nullable = true)
	public WorkTime night;

	/**
	 * 巡检
	 */
	@OneToMany(cascade = { CascadeType.REMOVE }, mappedBy = "schedule")
	public List<NightCheck> nightCheckList;
}
